package com.pro.controller;

import com.pro.pojo.JsBeforeUser;
import com.pro.pojo.JsUserCouponUsed;
import com.pro.pojo.JsonData;
import com.pro.service.JsUserCouponUsedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/JsUserCouponUsed")
public class JsUserCouponUsedController {
    @Autowired
    JsUserCouponUsedService jucus;
    @RequestMapping(value = "/getAllJsBeforeUser")
    @ResponseBody
    public JsonData getAllJsBeforeUser(String account,String nickname){
        List<JsBeforeUser> allJsBeforeUser = jucus.getAllJsBeforeUser(account,nickname);
        return allJsBeforeUser!=null?JsonData.buildSuccess(allJsBeforeUser):JsonData.buildError("服务器异常");
    }
    @RequestMapping(value = "/getUsedCoupon")
    @ResponseBody
    public JsonData getUsedCoupon(JsUserCouponUsed param){
        Integer usedCoupon = jucus.getUsedCoupon(param);
        return usedCoupon!=null?JsonData.buildSuccess(usedCoupon):JsonData.buildError("服务器异常");
    }
    @RequestMapping(value = "/addJsUserCouponUsed")
    @ResponseBody
    public JsonData addJsUserCouponUsed(JsUserCouponUsed param){
        boolean b = jucus.addJsUserCouponUsed(param);
        return b?JsonData.buildSuccess(b):JsonData.buildError("服务器异常");
    }
    @RequestMapping(value = "/getAllstate")
    @ResponseBody
    public JsonData getAllstate(JsUserCouponUsed param){
        List<JsUserCouponUsed> allstate = jucus.getAllstate(param);
        return allstate!=null?JsonData.buildSuccess(allstate):JsonData.buildError("服务器异常");
    }
    @RequestMapping(value = "/getAllstateExpired")
    @ResponseBody
    public JsonData getAllstateExpired(JsUserCouponUsed param) {
        List<JsUserCouponUsed> allstateExpired = jucus.getAllstateExpired(param);
        return allstateExpired!=null?JsonData.buildSuccess(allstateExpired):JsonData.buildError("服务器异常");
    }


}
